package com.momoauth.common.security.config;

import com.momoauth.common.security.interceptor.AuthInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

public class AuthConfig implements WebMvcConfigurer {

    @Resource
    private AuthInterceptor interceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration registration = registry.addInterceptor(interceptor);
        registration.addPathPatterns("/**");  //拦截所有路径
        registration.excludePathPatterns( //排除不需要拦截的路径
                "/login/**"
        );
    }
}
